(ns mini.playground
  (:require [clojure.repl :refer [doc]]))

; This project has custom configuration.
; See .vscode/settings.json

; If you are new to Calva, you may want to use the command:
; Calva: Create a “Getting Started” REPL project
; which creates a project with a an interactive Calva (and Clojure) guide.

(defn greeting
  ([greet who] (println greet "," who "!"))
  ([who] (greeting "hello" who))
  ([] (greeting "hello" "world")))

(greeting)

(greeting "clojure")

(greeting "x" "y")

(defn do-nothing [x] x)

(do-nothing '(1 2 3))

(defn always-thing [& nums] 100)

(always-thing 1 2 3 4)

(apply + '(1 2 3 4))
(apply + 1 '(2 3 4))
(apply + 1 2 '(3 4))
(apply + 1 2 3 '(4))

[1 2 3]

(get [1 2 3] 0)
(count [1 2 3])
(vector 1 2 3)
(conj [1 2 3] 4)

(def v [1 2 3])

(conj v 3 4 5 6)

(def cards '(10 :ace :jack 9))

(first cards)

(rest cards)

(def stack '(:a :b))

(peek stack)
(peek stack)
(pop stack)

(def players #{"a","b","c"})
(conj players "d")
(conj players "d")
(disj players "b")
(contains? players "c")
(conj (sorted-set) "a" "c" "d" "b")

(def new-player ["e" "d" "g"])

(into players new-player)

(def sores {"Fred" 1400 "Bob" 1240 "Angela" 1224})

sores

(assoc sores "Sally" 0)
(assoc sores "Bob" 10)
(dissoc sores "Bob")
(get sores "Bob")

(sores "Bob")

(get sores "yjj" 2)
(sores "yjj" 3)
(contains? sores "Bob")
(find sores "Bob")
(keys sores)
(vals sores)

(zipmap players (repeat 0))
(into {} (map (fn [player] [player 0]) players))

;Representing application domain information
(def Person {:firstname "Kally" :last-name "Ken" :age 23 :occupation "Programmer"})
(get Person :age)
(Person :firstname)
(:last-name Person)
(:address Person "beijing")
(assoc Person :age 30)
(dissoc Person :occupation)
(def company {:name "WidgetCo"
              :address {:street "abc"
                        :city "beijjing"
                        :state "IL"}})

(get-in company [:address :state])
(assoc-in company [:address :city] "shanghai")

;;Records
#_{:clj-kondo/ignore [:namespace-name-mismatch]}
(ns my.data)
(defrecord Person [fname lname address])
(def yjj (->Person "a" "b" "c"))
(:fname yjj)
